using Mapster;
using SmartCommunity.Models;
using System.ComponentModel.DataAnnotations;

namespace SmartCommunity.Services.Workorder
{
    #region DTO属性映射
    /// <summary>
    /// 属性映射 WorkProcessDtoRegister
    /// </summary>
    public class WorkProcessDtoRegister : IRegister
    {
        public void Register(TypeAdapterConfig config)
        {
            // config.ForType<WorkProcessEntity, WorkProcessDto>().Map(d => d.DeptName, s => s.Dept.DeptName, s => s.Dept != null);
        }
    }
    #endregion

    #region 数据传输对象 WorkProcessDto
    /// <summary>
    /// 数据传输对象：工单处理过程记录
    /// </summary>
    public class WorkProcessDto : BaseDto
    {
        /// <summary>
        /// 处理过程ID
        /// </summary>
        public Guid ProcessId { get; set; }

        /// <summary>
        /// 工单id
        /// </summary>
        public Guid OrderId { get; set; }

        /// <summary>
        /// 处理内容描述
        /// </summary>
        [StringLength(2000, ErrorMessage = "处理内容描述 长度不能超过 2000.")]
        public string? Content { get; set; }

    }
    #endregion

    #region 数据查询对象
    /// <summary>
    /// 查询模型：工单处理过程记录
    /// </summary>
    public class WorkProcessQuery : AbstractQuery<WorkProcessEntity>
    {
        /// <summary>
        /// 主键ID多选查询
        /// </summary>
        public IEnumerable<Guid> Ids { get; set; } = [];

        /// <summary>
        /// 根据查询条件添加查询表达式
        /// </summary>
        protected override void MergeQueryExpression()
        {
            AddExpression(Ids.Any(), e => Ids.Contains(e.ProcessId));
            // AddStringExpression(RoleCode, r => r.RoleCode == RoleCode);
            // AddSearchExpression(s => o => o.RoleCode.Contains(s) || o.RoleName.Contains(s));
            // AddDateExpression(start => e => e.CreatedTime >= start, end => e => e.CreatedTime <= end);
        }
    }
    #endregion
}
